
// import store from '../store'
// const defaultSettings = require('@/settings.js')
// const modules = {
//   '/oldProcess/informate/0': [
//     { title: '参评教师', width: 600, type: 'teacher', show: true, right: 0 },
//     { title: '教师资料', width: 120, type: 'teacher_information', show: true, right: 0 },
//     { title: '操 作', width: 150, type: 'group_operation', show: true }
//   ],
//   '/oldProcess/faculty_group_assessment/6': [
//     { title: '参评教师', width: 200, type: 'teacher', show: true, right: 0 },
//     { title: '自评等级', width: 120, type: 'self_evaluation_grade', show: true, right: 0 },
//     { title: '评价专家', width: 270, type: 'expert', show: true, right: 0 },
//     { title: '评价评分', width: 140, type: 'expert_score', show: true, right: 0 },
//     { title: '评审结果', width: 180, type: 'evaluate_result', show: true, right: 0 },
//     { title: '评定委员', width: 200, type: 'assess_committee', show: true, right: 0 },
//     { title: '评定结果', width: 150, type: 'assess_result', show: true, right: 0 },
//     { title: '评定统计', width: 140, type: 'assess_statistic', show: true, right: 0 },
//     { title: '教师资料', width: 120, type: 'teacher_information', show: true, right: 0 },
//     { title: '操 作', width: 150, type: 'operation', show: true }
//   ],
//   '/oldProcess/faculty_group_assessment/7': [
//     { title: '参评教师', width: 200, type: 'teacher', show: true, right: 0 },
//     { title: '自评等级', width: 120, type: 'self_evaluation_grade', show: true, right: 0 },
//     { title: '评价专家', width: 270, type: 'expert', show: true, right: 0 },
//     { title: '评价评分', width: 140, type: 'expert_score', show: true, right: 0 },
//     { title: '评审结果', width: 180, type: 'evaluate_result', show: true, right: 0 },
//     { title: '评定委员', width: 200, type: 'assess_committee', show: true, right: 0 },
//     { title: '评定结果', width: 150, type: 'assess_result', show: true, right: 0 },
//     { title: '评定统计', width: 140, type: 'assess_statistic', show: true, right: 0 },
//     { title: '教师资料', width: 120, type: 'teacher_information', show: true, right: 0 },
//     { title: '操 作', width: 150, type: 'operation', show: true }
//   ],
//   '/oldProcess/assessment/3': [
//     { title: '参评教师', width: 200, type: 'teacher', show: true, right: 0 },
//     { title: '自评等级', width: 120, type: 'self_evaluation_grade', show: true, right: 0 },
//     { title: '评价专家', width: 270, type: 'expert', show: true, right: 0 },
//     { title: '评价评分', width: 140, type: 'expert_score', show: true, right: 0 },
//     { title: '评审结果', width: 180, type: 'evaluate_result', show: true, right: 0 },
//     { title: '教师资料', width: 120, type: 'teacher_information', show: true, right: 0 },
//     { title: '操 作', width: 150, type: 'operation', show: true }
//   ],
//   '/oldProcess/assessment/4': [
//     { title: '参评教师', width: 200, type: 'teacher', show: true, right: 0 },
//     { title: '自评等级', width: 120, type: 'self_evaluation_grade', show: true, right: 0 },
//     { title: '评价专家', width: 270, type: 'expert', show: true, right: 0 },
//     { title: '评价评分', width: 140, type: 'expert_score', show: true, right: 0 },
//     { title: '评审结果', width: 180, type: 'evaluate_result', show: true, right: 0 },
//     { title: '教师资料', width: 120, type: 'teacher_information', show: true, right: 0 },
//     { title: '操 作', width: 150, type: 'operation', show: true }
//   ],
//   '/oldProcess/assessment/6': [
//     { title: '参评教师', width: 200, type: 'teacher', show: true, right: 0 },
//     { title: '自评等级', width: 120, type: 'self_evaluation_grade', show: true, right: 0 },
//     { title: '评价专家', width: 270, type: 'expert', show: true, right: 0 },
//     { title: '评价评分', width: 140, type: 'expert_score', show: true, right: 0 },
//     { title: '评审结果', width: 180, type: 'evaluate_result', show: true, right: 0 },
//     { title: '教师资料', width: 120, type: 'teacher_information', show: true, right: 0 },
//     { title: '操 作', width: 150, type: 'operation', show: true }
//   ],
//   '/oldProcess/assessment/7': [
//     { title: '参评教师', width: 200, type: 'teacher', show: true, right: 0 },
//     { title: '自评等级', width: 120, type: 'self_evaluation_grade', show: true, right: 0 },
//     { title: '评价专家', width: 270, type: 'expert', show: true, right: 0 },
//     { title: '评价评分', width: 140, type: 'expert_score', show: true, right: 0 },
//     { title: '评审结果', width: 180, type: 'evaluate_result', show: true, right: 0 },
//     { title: '教师资料', width: 120, type: 'teacher_information', show: true, right: 0 },
//     { title: '操 作', width: 150, type: 'operation', show: true }
//   ],
//   '/oldProcess/evaluation/2': [
//     { title: '参评教师', width: 200, type: 'teacher', show: true, right: 0 },
//     { title: '自评等级', width: 120, type: 'self_evaluation_grade', show: true, right: 0 },
//     { title: '评价专家', width: 270, type: 'expert', show: true, right: 0 },
//     { title: '评审进度', width: 160, type: 'evaluation_progress', show: true, right: 0 },
//     { title: '教师资料', width: 120, type: 'teacher_information', show: true, right: 0 },
//     { title: '操 作', width: 150, type: 'operation', show: true }
//   ],
//   '/oldProcess/evaluation/5': [
//     { title: '参评教师', width: 200, type: 'teacher', show: true, right: 0 },
//     { title: '自评等级', width: 120, type: 'self_evaluation_grade', show: true, right: 0 },
//     { title: '评价专家', width: 270, type: 'expert', show: true, right: 0 },
//     { title: '评审进度', width: 160, type: 'evaluation_progress', show: true, right: 0 },
//     { title: '教师资料', width: 120, type: 'teacher_information', show: true, right: 0 },
//     { title: '分配专家', width: 150, type: 'operation', show: true }
//   ],
//   '/oldProcess/complete/4': [
//     { title: '参评教师', width: 200, type: 'teacher', show: true, right: 0 },
//     { title: '自评等级', width: 120, type: 'self_evaluation_grade', show: true, right: 0 },
//     { title: '评价专家', width: 270, type: 'expert', show: true, right: 0 },
//     { title: '评价评分', width: 140, type: 'expert_score', show: true, right: 0 },
//     { title: '评价结果', width: 180, type: 'final_result', show: true, right: 0 },
//     { title: '教师资料', width: 120, type: 'teacher_information', show: true, right: 0 },
//     { title: '评审明细', width: 150, type: 'operation', show: true }
//   ],
//   '/oldProcess/complete/7': [
//     { title: '参评教师', width: 200, type: 'teacher', show: true, right: 0 },
//     { title: '自评等级', width: 120, type: 'self_evaluation_grade', show: true, right: 0 },
//     { title: '评价专家', width: 270, type: 'expert', show: true, right: 0 },
//     { title: '评价评分', width: 140, type: 'expert_score', show: true, right: 0 },
//     { title: '评价结果', width: 180, type: 'final_result', show: true, right: 0 },
//     { title: '教师资料', width: 120, type: 'teacher_information', show: true, right: 0 },
//     { title: '评审明细', width: 150, type: 'operation', show: true }
//   ],
//   '/oldProcess/complete/8': [
//     { title: '参评教师', width: 200, type: 'teacher', show: true, right: 0 },
//     { title: '自评等级', width: 120, type: 'self_evaluation_grade', show: true, right: 0 },
//     { title: '评价专家', width: 270, type: 'expert', show: true, right: 0 },
//     { title: '评价评分', width: 140, type: 'expert_score', show: true, right: 0 },
//     { title: '评价结果', width: 180, type: 'final_result', show: true, right: 0 },
//     { title: '评定委员', width: 200, type: 'assess_committee', show: defaultSettings.project_config.evaluation_course.config.department_assess || false, right: 0 },
//     { title: '评定结果', width: 150, type: 'assess_result', show: defaultSettings.project_config.evaluation_course.config.department_assess || false, right: 0 },
//     { title: '评定统计', width: 140, type: 'assess_statistic', show: defaultSettings.project_config.evaluation_course.config.department_assess || false, right: 0 },
//     { title: '教师资料', width: 120, type: 'teacher_information', show: true, right: 0 },
//     { title: '评审明细', width: 150, type: 'operation', show: true }
//   ],
//   '/oldProcess/audit/1': [
//     { title: '参评教师', width: 600, type: 'teacher', show: true, right: 0 },
//     { title: '自评等级', width: 120, type: 'self_evaluation_grade', show: true, right: 0 },
//     { title: '审核资料', width: 220, type: 'audit_information', show: true, right: 0 },
//     { title: '操作', width: 420, type: 'operation', show: true, right: 0 }
//   ]
// }
const tableColumn = {
  teacher: { title: '参评教师', width: 600, type: 'teacher', show: true, right: 0 },
  self_evaluation_grade: { title: '自评等级', width: 120, type: 'self_evaluation_grade', show: false, right: 0 },
  audit_information: { title: '审核资料', width: 220, type: 'audit_information', show: true, right: 0 },
  expert: { title: '评价专家', width: 270, type: 'expert', show: true, right: 0 },
  evaluation_progress: { title: '评审进度', width: 160, type: 'evaluation_progress', show: true, right: 0 },
  expert_score: { title: '评价评分', width: 140, type: 'expert_score', show: true, right: 0 },
  final_result: { title: '评价结果', width: 180, type: 'final_result', show: true, right: 0 },
  evaluate_result: { title: '评审结果', width: 180, type: 'evaluate_result', show: true, right: 0 },
  assess_committee: { title: '评定委员', width: 200, type: 'assess_committee', show: false, right: 0 },
  assess_result: { title: '评定结果', width: 150, type: 'assess_result', show: false, right: 0 },
  assess_statistic: { title: '评定统计', width: 140, type: 'assess_statistic', show: false, right: 0 },
  teacher_information: { title: '教师资料', width: 120, type: 'teacher_information', show: true, right: 0 },
  evaluate_detail: { title: '评审明细', width: 150, type: 'evaluate_detail', show: true, right: 0 },
  group_operation: { title: '操作', width: 150, type: 'group_operation', show: true, right: 0 },
  operation: { title: '操作', width: 420, type: 'operation', show: true, right: 0 }
}

let currentTable = []

export const tableHeader = (columnShow) => {
  const data = []
  const columnShowKey = Object.keys(columnShow)
  columnShowKey.forEach(key => {
    // teacher: { title: '参评教师', show: true }
    // teacher_information: { title: '教师资料', show: !!operation_teacher_list.length }
    // group_operation: { title: '操作', show: !!operation_group_list.length }
    // self_evaluation_grade: { title: '自评等级', show: is_self_evaluation_grade }
    // audit_information: { title: '自评等级', show: true }
    // expert: { title: '评价专家', show: true },
    // evaluation_progress: { title: '评审进度', show: true },
    // final_result: { title: '评审进度', show: !!grade_or_score.length },
    // expert_score: { title: '评价评分', show: true },
    if (key in columnShow && columnShow[key].show) {
      tableColumn[key].title = 'title' in columnShow[key] ? columnShow[key].title : tableColumn[key].title
      tableColumn[key].show = 'show' in columnShow[key] ? columnShow[key].show : tableColumn[key].show
      tableColumn[key].width = 'width' in columnShow[key] ? columnShow[key].width : tableColumn[key].width
      data.push(tableColumn[key])
    }
  })
  data.forEach((item, index) => {
    item.right = 0
    // 设置线条显示
    data.slice(index).forEach(el => {
      // if (el.show) item.right += el.width
      item.right += el.width
    })
  })
  // console.log('conditionShow', conditionShow)
  // console.log('tableColumn', tableColumn)
  // modules[store.state.app.routePath].forEach((item, index) => {
  //   item.right = 0
  //   // 设置线条显示
  //   modules[store.state.app.routePath].slice(index).forEach(el => {
  //     if (el.show) item.right += el.width
  //   })
  //   // 设置显示
  //   if (item.type in conditionShow) {
  //     item.show = conditionShow[item.type]
  //     if (conditionShow[item.type]) {
  //       data.push(item)
  //     }
  //   } else if (item.show) {
  //     data.push(item)
  //   }
  // })
  console.log('datadatadata', data)
  currentTable = data
  return JSON.stringify(data)
}

/**
 * 获取总的列表宽度
 * @param {*} columnShow 与tableHeader相同
 * @returns 像素px
 */
export const tableTotalWidth = (columnShow) => {
  let width = 0
  const columnShowKey = Object.keys(columnShow)
  columnShowKey.forEach(key => {
    if (key in columnShow && columnShow[key].show) {
      width += tableColumn[key].width
    }
  })
  console.log('widthwidthwidth', width)
  return width + 'px'
}

/**
 * 获取每列的宽
 * @param {*} type 类型
 * @returns 像素px
 */
export const tableRowWidth = (type) => {
  return tableColumn[type] ? tableColumn[type].width + 'px' : '0px'
}

/**
 * 设置表单线条
 * @param {*} type 浮动距离标识
 * @returns 像素px
 */
export const tableColumnLine = (type) => {
  let width = 0
  let arr = []
  currentTable.forEach((item, index) => {
    if (type === item.type) {
      arr = currentTable.slice(index)
      arr.forEach(el => {
        if (el.show) width += el.width
      })
    }
  })
  return width + 'px'
}

